package com.zmn.oms.zmn.business.impl.serviceItem;

import com.zmn.oms.business.interfaces.product.OrderProductExtendBService;
import com.zmn.oms.business.interfaces.serviceitem.OrderServiceItemBService;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.dto.serviceitem.AddOrderServiceItemDTO;
import com.zmn.oms.model.entity.product.OrderProductExtend;
import com.zmn.oms.model.entity.serviceitem.OrderServiceItem;
import com.zmn.oms.services.interfaces.serviceitem.OrderServiceItemService;
import com.zmn.oms.zmn.business.interfaces.serviceItem.ZsOrderServiceItemBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 类描述：啄木鸟-工单服务项
 *
 * @author heciqi
 * @date 2018/12/06 14:41
 */
@Service
public abstract class ZsOrderServiceItemBServiceImpl implements ZsOrderServiceItemBService {

	@Autowired
	private OrderServiceItemBService orderServiceItemBService;
	@Autowired
	private OrderProductExtendBService orderProductExtendBService;
	@Autowired
	private OrderServiceItemService orderServiceItemService;

	/**
	 * 获取订单产品扩展
	 *
	 * @param orderId
	 * @return
	 */
	@Override
	public List<OrderProductExtend> getOrderProductExtend(Long orderId) throws OmsBaseException {
		return orderProductExtendBService.getOrderProductExtend(orderId);
	}

	/**
	 * 根据订单id查询服务项列表
	 *
	 * @param orderId
	 * @return
	 */
	@Override
	public List<OrderServiceItem> listByOrderId(Long orderId) {
		return orderServiceItemService.listByOrderId(orderId);
	}

	/**
	 * 根据订单id，产品扩展id查询服务项列表
	 *
	 * @param orderId
	 * @param proExtId
	 * @return
	 */
	@Override
	public List<OrderServiceItem> listByOrderIdAndProExtId(Long orderId, Long proExtId) {
		return orderServiceItemService.listByOrderIdAndProExtId(orderId, proExtId);
	}

	/**
	 * 新增订单服务项
	 *
	 * @param addOrderServiceItemDTO
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void insertServiceItem(AddOrderServiceItemDTO addOrderServiceItemDTO) throws OmsBaseException {
		orderServiceItemBService.insertServiceItem(addOrderServiceItemDTO);
	}

	/**
	 * 删除订单服务项
	 *
	 * @param orderId
	 */
	@Override
	public void deleteServiceItemByOrderId(Long orderId) {
		orderServiceItemBService.deleteServiceItemByOrderId(orderId);
	}
}
